from playwright.async_api import async_playwright, expect, Playwright
import asyncio
async def run(playwright: Playwright) -> None:
    browser = await playwright.firefox.launch(headless=False)
    context = await browser.new_context()
    page = await context.new_page()
    await page.goto("https://yiyan.baidu.com/") 
    await page.get_by_text("退出登录").wait_for(timeout=300000)
    await page.locator("#eb_model_footer").get_by_role("paragraph").fill("你好")
    footer = page.locator("#eb_model_footer")
    # /html/body/div[1]/div[2]/div[2]/div[2]/div[1]/div[3]/div/div[3]/div[1]/div[2]/span
    span_elements = page.locator("#eb_model_footer").locator("div >> div >> div >> div >> span")
    await span_elements.last.click()
    page.pause()
    # ---------------------
    await page.wait_for_event("message")
    await context.close()
    await browser.close()

async def main():
    async with async_playwright() as playwright:
        await run(playwright)

# 运行异步函数
if __name__ == "__main__":
    asyncio.run(main())